Customizing IntelliSense Using FoxCode

You can modify or add to the functionality of IntelliSense in Visual FoxPro by modifying the contents of FoxCode.dbf. By default, the FoxCode.dbf table is installed in your Windows user application folder.

Note   When you launch Visual FoxPro for the first time, a duplicate of FoxCode.dbf is copied to your personal Windows application data location. This can be reset in the File Locations tab of the Options dialog box.

To customize IntelliSense

FoxCode.dbf Structure

Field name Type (size) Description
Type C (1) Specifies the type of reference contained in this record.
Abbrev C (24) Represents the minimum set of keystrokes that trigger IntelliSense for this item.
Expanded C (26) Specifies what is inserted at cursor.
Cmd C (15) Specifies the command script to execute for this item.
Tip M Specifies the contents of the Quick Tip info (parameters).
Data M Specifies all List values or any Visual FoxPro code specific to this item and can, optionally, contain other script text.
Case C (1) Specifies how the text is replaced.
U = UPPER
L = lower
M or <empty> = Mixed
P = Proper
X = Unchanged

Any value you specify in this field of the version record sets a global default for individual records that do not have a Case setting.

Save L Specifies whether the record is saved when the field is updated.
TimeStamp T Represents the Unique timestamp for this item.
Source M Specifies the source of record content. Core contents shipped with this version of Visual FoxPro are specified as RESERVED here. This field can contain path and file name of user-supplied records.
UniqueID C (10) Specifies a unique identifier for this record.
User M Specifies user information.

Valid FoxCode.dbf Type Column Values

Value Type Description
C Command Specifies Visual FoxPro command and auto-completion items.
F Function Specifies Visual FoxPro functions used in Quick Info tips.
O COM Component Specifies the COM Typelib reference for use with AS drop-down list.
P Property Specifies Visual FoxPro properties.
S Script Specifies that the data field contains Visual FoxPro script to be run.
T Typing Specifies items that appear in the AS drop-down list or when referenced as an object.
U User Specifies user-defined auto-expansion items. These items, unlike Command item types, do not have to be absolute pattern matches.
V Version Specifies the special record for version information (reserved).

COM Component Item Type

COM Component item type is a FoxCode.dbf record whose contents will appear in an AS clause drop-down list, such as a Typing item type record. The COM Typing item type record represents the name of the COM type library that contains a collection of classes (ProgIDs), instances of which can be created by Visual FoxPro using the CreateObject( ) function.

The Data field of this type record contains the GUID and version for the type library rather than code, as in the following table:

Field Name Example
Type O
Abbrev Excel
CMD {}
Tip Microsoft Excel 9.0 Object Library
Data {00020813-0000-0000-C000-000000000046}#1.3

Command Item Type

Command item type is a FoxCode.dbf record whose contents represent Visual FoxPro command completion or substitution statements as in the following table:

Field Name Example
Type C
Abbrev MC
Expanded MODIFY COMMAND

You trigger the content of these records in IntelliSense by typing either the Abbrev field or the expanded value contents followed by a space in an editor.

Function Item Type

Function item type is a FoxCode.dbf record whose contents represent Visual FoxPro functions, procedures, and user-defined functions as in the following table:

Field Name Example
Type F
Abbrev FCOU
Expanded FCOUNT
Tip [nWorkArea | cTableAlias]

You display the Tip field content of these records in a Tip window by typing the Abbrev value or the expanded value followed by a left parenthesis.

Property Item Type

Property item type is a FoxCode.dbf record whose contents specify a property. Use this type to add a custom Value Editor when assigning values to the specified property.

The following is an example of specifying value editors for properties (P type entries in table):

Field Name Example
Type P
Abbrev .Picture
Cmd {picture}

The Cmd field contains a reference, "{picture}", to a FoxCode script record whose ABBREV field contains the value "picture" (see the Script item type for more information). By typing ".picture=" you run the code contained in the script record related to this property record.

Except in Type = "T" or "O" records, if the Cmd field contains only beginning and ending braces ("{}") with no script reference, the record contains its own script in the Data field as in the following table:

Field Name Example
Type C
Abbrev NOW
Cmd {}
Data LPARAMETER oFoxCode
RETURN TRANSFORM(DATE( ))

Script Item Type

Script item type is a FoxCode.dbf record that can contain text as code in its data field. Another record executes this code by referencing it in the Cmd field. This type of record can contain the following:

  • FoxCode in Data field to be evaluated to text.

  • An ID in the Cmd field that references another record that contains the code. By placing code in a separate Script item type as in the following table, you enable multiple items to reference the same code:

    {picture}
    
    Field Name Example
    Type S
    Abbrev Picture
    Data (In the Memo field)
    LPARAMETER oFoxcode
    LOCAL lcPicture
    oFoxcode.valuetype="V"
    lcPicture = getpict()
    IF LEN(lcPicture) > 0 
       lcPicture = ['] + lcPicture+ [']
    ENDIF
    RETURN lcPicture

In this example, a Property item type record with "picture" in the ABBREV field references this Script item type record and runs the code in the Data field, displaying the Open Picture dialog box.

The script in Script records must contain a PARAMETERS or LPARAMETERS statement to accommodate the object reference.

The Return value replaces the typed text. If the return value evaluates to an empty string (""), Visual FoxPro leaves the typed text unchanged.

Each script called by IntelliSense must contain a parameter that is passed to the FoxCode parameter object. This object contains metadata detailing how the script was called, including the source record in the FoxCode table. For details, see FoxCode Object Reference.

Typing Item Type

Typing item type is a FoxCode.dbf record that represents the contents of an item displayed in the drop-down list of an AS clause. Optionally, the Data field of this record can contain code whose return value is inserted at the screen cursor location. If you include text in the Data field, end it with a RETURN statement.

Field Name Example
Type T
Abbrev CommandButton

User Item Type

User item type is a FoxCode.dbf record used to specify abbreviations for user-defined content as in the following table. Unlike the Command item type, the User item type abbreviation does not have to be the same as the initial characters of the expansion content.

Field Name Example
Type U
Abbrev MYADDRESS
Expanded 101 Main Street

Version Item Type

Version item type is the FoxCode.dbf record used for default settings and to track version information. This is reserved for internal use.

Field Name Example
Type V
Expanded <Identifies latest version of FoxCode> For internal use.

See Also

IntelliSense Overview | Using Scripting in FoxCode.dbf | Visual FoxPro IntelliSense Manager Window | Auto Table/Field/Variable Names | Auto MRU (Most Recently Used) Files | IntelliSense Support in Visual FoxPro | Using IntelliSense in Visual FoxPro | FoxCode Object